import { getSmsPlateList, getMailPlateList } from '@/service/getData'
import * as type from '@/store/mutation-types'
const state = {
  // 短信平台列表
  smsPltList: {
    data: []
  },
  // 邮件平台列表
  mailPltList: {
    data: []
  }
}
const actions = {
  // 短信平台列表
  async getSmsPlateList ({commit, state}, payload) {
    let res = await getSmsPlateList(payload)
    commit(type.SET_SMSPLT_LIST, res.data.data)
    return res
  },
  // 邮件平台列表
  async getMailPlateList ({commit, state}, payload) {
    let res = await getMailPlateList(payload)
    commit(type.SET_MAILPLT_LIST, res.data.data)
    return res
  }
}
const mutations = {
  // 短信平台列表
  [type.SET_SMSPLT_LIST] (state, payload) {
    if (payload.length > 0) {
      state.smsPltList.data = payload
    }
  },
  // 邮件平台列表
  [type.SET_MAILPLT_LIST] (state, payload) {
    if (payload.length > 0) {
      state.mailPltList.data = payload
    }
  }
}
export default {
  state,
  actions,
  mutations
}
